package com.fm.financemanage.model.vo;



import com.fm.financemanage.model.po.SysRole;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@ApiModel("角色信息表")
public class SysRoleVo implements Serializable {
    /**
     * 角色ID
     */
    @ApiModelProperty("角色ID")
    private Long id;

    /**
     * 角色名称
     */
    @ApiModelProperty("角色名称")
    private String roleName;

    /**
     * 角色权限字符串
     */
    @ApiModelProperty("角色权限字符串")
    private String roleKey;

    /**
     * 显示顺序
     */
    @ApiModelProperty("显示顺序")
    private Integer roleSort;

    /**
     * 数据范围
     */
    @ApiModelProperty("数据范围")
    private String dataScope;

    /**
     * 角色状态（1正常 0停用）
     */
    @ApiModelProperty("角色状态（1正常 0停用）")
    private String state;

    /**
     * 删除标志（0代表存在 1代表删除）
     */
    @ApiModelProperty("删除标志（0代表存在 1代表删除）")
    private String hasDeleted;

    /**
     * 创建者
     */
    @ApiModelProperty("创建者")
    private String createBy;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    /**
     * 更新者
     */
    @ApiModelProperty("更新者")
    private String updateBy;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    private LocalDateTime updateTime;

    /**
     * 备注
     */
    @ApiModelProperty("备注")
    private String remark;
    @ApiModelProperty("菜单项")
    private Long[] menuIds;

    @ApiModelProperty("标记")
    private boolean flag;

    public static SysRole build(SysRoleVo sysRoleVo){
        SysRole sysRole = new SysRole();
        sysRole.setCreateBy(sysRoleVo.getCreateBy());
        sysRole.setCreateTime(sysRoleVo.getCreateTime());
        sysRole.setDataScope(sysRoleVo.getDataScope());
        sysRole.setHasDeleted(sysRoleVo.getHasDeleted());
        sysRole.setId(sysRoleVo.getId());
        sysRole.setRemark(sysRoleVo.getRemark());
        sysRole.setRoleKey(sysRoleVo.getRoleKey());
        sysRole.setRoleName(sysRoleVo.getRoleName());
        sysRole.setRoleSort(sysRoleVo.getRoleSort());
        sysRole.setState(sysRoleVo.getState());
        sysRole.setUpdateBy(sysRoleVo.getUpdateBy());
        sysRole.setUpdateTime(sysRoleVo.getUpdateTime());
        return sysRole;
    }


    public static SysRoleVo buildVo(SysRole sysRole){
        SysRoleVo sysRoleVo = new SysRoleVo();
        sysRoleVo.setCreateBy(sysRole.getCreateBy());
        sysRoleVo.setCreateTime(sysRole.getCreateTime());
        sysRoleVo.setDataScope(sysRole.getDataScope());
        sysRoleVo.setHasDeleted(sysRole.getHasDeleted());
        sysRoleVo.setId(sysRole.getId());
        sysRoleVo.setRemark(sysRole.getRemark());
        sysRoleVo.setRoleKey(sysRole.getRoleKey());
        sysRoleVo.setRoleName(sysRole.getRoleName());
        sysRoleVo.setRoleSort(sysRole.getRoleSort());
        sysRoleVo.setState(sysRole.getState());
        sysRoleVo.setUpdateBy(sysRole.getUpdateBy());
        sysRoleVo.setUpdateTime(sysRole.getUpdateTime());
        return sysRoleVo;
    }

    private static final long serialVersionUID = 1L;
}
